package com.zhiyun.store;

import java.util.Comparator;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

import com.zhiyun.common.YYCallUtils;

public class CallHistory {

	public String targetNo;
	public String callName;
	public String callTimeDesc;
	public Long callTime;
	public String callTotal;
	public List<CallLogItem> items = new LinkedList<CallLogItem>();
	public final static Comparator<CallHistory> COMPARATOR = new Comparator<CallHistory>() {

		@Override
		public int compare(CallHistory lhs, CallHistory rhs) {
			return (int) (rhs.callTime-lhs.callTime  );
		}
	};

	public void evalute() {
		targetNo = this.getTargetNo();
		callName = this.getCallName();
		callTime = items.get(0).callTime;
		callTimeDesc = this.getCallTime();
		callTotal = String.valueOf(this.getCallTotal());
	}

	private String getTargetNo() {
		return items.isEmpty() ? null : items.get(0).targetNo;
	}

	private String getCallName() {
		return YYCallUtils.queryNameByPhoneNo(this.getTargetNo());
	}

	private Integer getCallTotal() {
		return items.size();
	}

	private String getCallTime() {
		return items.isEmpty() ? null : YYCallUtils.getDateTimeDesc(new Date(
				items.get(0).callTime));
	}

}
